package com.linkage.jz.bankruptcy.activity.Project;

import android.app.ActionBar;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import com.linkage.jz.bankruptcy.R;
import com.linkage.jz.bankruptcy.activity.Person.PersonSettingReadMeActivity;
import com.linkage.jz.bankruptcy.bean.MyProInfo;
import com.linkage.jz.bankruptcy.fragment.Project.OtherUserListFrgment;
import com.linkage.jz.bankruptcy.widget.PublicPopupMenu;
import com.linkage.jz.bankruptcy.widget.ShapeLoadingDialog;
import com.linkage.seapeak.activity.message.MultiMessageHistoryActivity;
import com.linkage.seapeak.activity.message.MultiSelectActivity;
import com.linkage.seapeak.base.BaseWhiteActivity;


/**
 * A login screen that offers login via email/password.
 */
public class OtherUserListActivity extends BaseWhiteActivity {
    private static final String TAG = PersonSettingReadMeActivity.class.getSimpleName();
    private ShapeLoadingDialog shapeLoadingDialog;
    private static MyProInfo mInfo;
    private PublicPopupMenu popupMenu;

    private View menu;

    public static void start(Context context, MyProInfo info) {
        mInfo = info;
        Intent intent = new Intent(context, OtherUserListActivity.class);
        context.startActivity(intent);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pro_otheruserlist, "其他成员");

        initview();
        shapeLoadingDialog = new ShapeLoadingDialog(this);

        init();
        popupMenu = new PublicPopupMenu(this, "群发消息", "群发消息记录", "", "", "");
    }

    //初始化视图
    private void initview() {
        menu = addMenu(new MenuAction(new OnClickListener(){

           @Override
           public void onClick(View v) {
               popupMenu.showLocation(v);// 设置弹出菜单弹出的位置
               // 设置回调监听，获取点击事件
               popupMenu.setOnItemClickListener(new PublicPopupMenu.OnItemClickListener() {

                   @Override
                   public void onClick(PublicPopupMenu.MENUITEM item, String str) {
                       // TODO Auto-generated method stub
//                        Toast.makeText(ManagerListActivity.this, str, Toast.LENGTH_LONG).show();
                       if ("0".equalsIgnoreCase(str)) {
                           //群发消息
                           MultiSelectActivity.start(OtherUserListActivity.this, mInfo.getId());
                       } else {
                           //群发消息记录
                           MultiMessageHistoryActivity.start(OtherUserListActivity.this, mInfo.getId());
                       }
                   }
               });
           }
       }, "", R.drawable.more_black));
       menu.setVisibility(View.GONE);
    }

    public void showMenu(boolean isShow) {
//        menu.setVisibility(isShow ? View.VISIBLE : View.GONE);
    }

    private void init() {
        OtherUserListFrgment groupChildrenCollect = new OtherUserListFrgment();
        Bundle bundle = new Bundle();
        bundle.putString("proid", mInfo.getId());//这里的values就是我们要传的值
        if(mInfo.getAuth()!=null) {
            try {
                bundle.putString("openAuth", mInfo.getAuth().getOpenAdministratorInfo() + "");//这里的values就是我们要传的值
            }catch (Exception ex)
            {
                ex.printStackTrace();
                bundle.putString("openAuth","true");
            }
        }else{
            bundle.putString("openAuth","true");
        }
        groupChildrenCollect.setArguments(bundle);

        getSupportFragmentManager().beginTransaction().replace(R.id.content, groupChildrenCollect).commitAllowingStateLoss();
    }

}


